﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace ESoft.Core.Utils.Extensions
{
    public static class ExpressionExtensions
    {
        /// <summary>
        /// 判断是否指定的Linq表达式类型
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="expression"></param>
        /// <returns></returns>
        public static bool Is<T>(this Expression expression) where T : Expression
        {
            return expression is T;
        }
        /// <summary>
        /// 转换成指定的Linq表达式
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="expression"></param>
        /// <returns></returns>
        public static T As<T>(this Expression expression) where T : Expression
        {
            return expression as T;
        }

    }
}
